package com.zhou.mango.dao;

import com.zhou.mango.entity.Order;
import com.zhou.mango.sharting.OrderDatabaseShardingStrategy;
import com.zhou.mango.sharting.OrderTableShardingStrategy;
import org.jfaster.mango.annotation.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Mr.zhou
 */
@DB(table = "t_order")
@Sharding(
        databaseShardingStrategy = OrderDatabaseShardingStrategy.class,
        tableShardingStrategy = OrderTableShardingStrategy.class
)
public interface ShardingOrderDao {
    @SQL("insert into #table(id, uid, price, status) values(:id, :uid, :price, :status)")
    public void addOrder(@DatabaseShardingBy("uid") @TableShardingBy("uid") Order order);

    @SQL("select id, uid, price, status from #table where uid = :1")
    public List<Order> getOrdersByUid(@DatabaseShardingBy @TableShardingBy int uid);
}
